package com.yztc.orangeentertainment.ui.main.channalarticle;

import android.content.Context;

import com.yztc.orangeentertainment.bean.channalarticle.ChannalArticleAttitudeBean;
import com.yztc.orangeentertainment.bean.channalarticle.ChannalArticleFooterBean;
import com.yztc.orangeentertainment.bean.channalarticle.ChannalArticleIMGBean;
import com.yztc.orangeentertainment.bean.channalarticle.ChannalArticleInfoBean;
import com.yztc.orangeentertainment.bean.channalarticlecomment.ArticleBean;
import com.yztc.orangeentertainment.bean.channalarticlecomment.ArticleCommentAttitudeBean;
import com.yztc.orangeentertainment.bean.channalarticlecomment.ArticleCommentBean;
import com.yztc.orangeentertainment.config.ChannalUrlConfig;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2016/10/10.
 */
public class ChannalArticlePresenter implements ChannalArticleContract.Presenter {
    private ChannalArticleContract.Modle modle;
    private ChannalArticleContract.View view;

    public ChannalArticlePresenter(ChannalArticleContract.View view) {
        this.view = view;
        this.modle=new ChannalArticleModle();
    }
    @Override
    public void getChannalArticleFromNet(Context context, String id) {
        Map<String,String> map=new HashMap<>();
        map.put(ChannalUrlConfig.Params.ID, id);
        String type=ChannalUrlConfig.PATH.URl_CHANNALARTICLE_TYPE;
        map.put(SubscribeUrlConfig.Params.MAC, SubscribeUrlConfig.All_DefaultVaule.MAC_VALUE);
        map.put(SubscribeUrlConfig.Params.UID, SubscribeUrlConfig.All_DefaultVaule.UID_VALUE);
        map.put(SubscribeUrlConfig.Params.PF, SubscribeUrlConfig.All_DefaultVaule.PF_VALUE);
        map.put(SubscribeUrlConfig.Params.NET, SubscribeUrlConfig.All_DefaultVaule.NET_VALUE);
        map.put(SubscribeUrlConfig.Params.ACCESSTOKEN, SubscribeUrlConfig.All_DefaultVaule.ACCESSTOKEN_VALUE);
        map.put(SubscribeUrlConfig.Params.CHANNEL, SubscribeUrlConfig.All_DefaultVaule.CHANNEL_VALUE);
        map.put(SubscribeUrlConfig.Params.VER, SubscribeUrlConfig.All_DefaultVaule.VER_VALUE);
        map.put(SubscribeUrlConfig.Params.RES, SubscribeUrlConfig.All_DefaultVaule.RES_VALUE);
        modle.getChannalArticle(type, map, new OnLoadChannalArticleListener() {
            @Override
            public void onInfoSuccess(ChannalArticleInfoBean infoBean) {
                view.onChannalArticleInfoSucess(infoBean);
            }

            @Override
            public void onInfoFailure(String e) {
                view.onChannalArticleInfoFaild(e);
            }

            @Override
            public void onFooterlistSuccess(ChannalArticleFooterBean footerBean) {
                view.onChannalArticleFooterSucess(footerBean);
            }

            @Override
            public void onFooterlistFailure(String e) {
                view.onChannalArticleInfoFaild(e);
            }

            @Override
            public void onContentlistSuccess(List<String> contentlist, List<ChannalArticleIMGBean> imgBeanList) {
                view.onChannalArticleContentSucess(contentlist,imgBeanList);
            }

            @Override
            public void onContentlistFailure(String e) {
                view.onChannalArticleContentFaild(e);
            }

            @Override
            public void onAttitudelistSuccess(List<ChannalArticleAttitudeBean> attitudeBeanList) {
                view.onChannalArticleAttitudeSucess(attitudeBeanList);
            }

            @Override
            public void onAttitudelistFailure(String e) {
                view.onChannalArticleAttitudeFaild(e);
            }

        },context);
    }


    @Override
    public void getChannalArticleFromDb() {

    }

    @Override
    public void getChannalArticleCommentFromNet(Context context, String id) {
        Map<String,String> map=new HashMap<>();
        map.put(ChannalUrlConfig.Params.ID, id);
        String type=ChannalUrlConfig.PATH.URL_CHANNALARTICLECOMMENT_TYPE;
        map.put(SubscribeUrlConfig.Params.MAC, SubscribeUrlConfig.All_DefaultVaule.MAC_VALUE);
        map.put(SubscribeUrlConfig.Params.UID, SubscribeUrlConfig.All_DefaultVaule.UID_VALUE);
        map.put(SubscribeUrlConfig.Params.PF, SubscribeUrlConfig.All_DefaultVaule.PF_VALUE);
        map.put(SubscribeUrlConfig.Params.NET, SubscribeUrlConfig.All_DefaultVaule.NET_VALUE);
        map.put(SubscribeUrlConfig.Params.ACCESSTOKEN, SubscribeUrlConfig.All_DefaultVaule.ACCESSTOKEN_VALUE);
        map.put(SubscribeUrlConfig.Params.CHANNEL, SubscribeUrlConfig.All_DefaultVaule.CHANNEL_VALUE);
        map.put(SubscribeUrlConfig.Params.VER, SubscribeUrlConfig.All_DefaultVaule.VER_VALUE);
        map.put(SubscribeUrlConfig.Params.RES, SubscribeUrlConfig.All_DefaultVaule.RES_VALUE);
        modle.getChannalArticleComment(type, map, new OnLoadChannalArticleCommentListener() {


            @Override
            public void onCommentAttitudelistSuccess(ArticleCommentAttitudeBean attitudeBean, ArticleBean articleBean) {
                view.onChannalArticleCommentAttitudeSucess(attitudeBean,articleBean);
            }

            @Override
            public void onCommentAttitudelistFailure(String e) {
                view.onChannalArticleCommentAttitudeFaild(e);
            }

            @Override
            public void onCommentBeanSuccess(ArticleCommentBean commentBean) {
                view.onChannalArticleCommentSucess(commentBean);
            }

            @Override
            public void onCommentBeanFailure(String e) {
                view.onChannalArticleCommentFaild(e);
            }
        },context);
    }

    @Override
    public void getChannalArticleCommentFromDb() {

    }
}